<?php
//session_start();
require_once '../models/Users.php';
	$session_user_id=0;
	$session_user_email;
	// there is an admin value in session
	if(isset($_SESSION["session_user_email_admin"])&&isset($_SESSION["session_user_password_admin"])){
		$session_user_email=$_SESSION["session_user_email_admin"];
		$session_user_password=$_SESSION["session_user_password_admin"];
		// check user and password
		$row=Users::checkUserLogin($session_user_email,$session_user_password);
		if(isset($row['userID'])){
			$status=$row['status'];
			// check user status
			if($status==USER_VALUE_ACTIVE){
				$session_user_id=(int)$row['userID'];
				$session_user_fullName=$row['f_name'].' '.$row['l_name'];
				$session_user_email=$row['email'];
			}
		}else{
			$session_user_id=-1;
		}
	}
	// check login
	if(!isset($session_user_id)||$session_user_id==0){
		header('Location: ../admin/login_admin.php');
	}
	// check session
	if($session_user_id==-1){
		header('Location: ../admin/login_admin.php');
	}
?>